xen/x86/alternatives: Do not use sync_core() to serialize I$
authorBorislav Petkov <bp@suse.de>
Sat, 3 Dec 2016 15:02:58 +0000 (16:02 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 31 May 2017 16:54:19 +0000 (17:54 +0100)
commitb01c2fb5834aea0328db55c310caa34173021d3d
treed9f3999039db8a4efdbf104f38d2721001bd3655
parent78825e1c60faadf99d9ed6c1a01a617b7543f506
xen/x86/alternatives: Do not use sync_core() to serialize I$

We use sync_core() in the alternatives code to stop speculative
execution of prefetched instructions because we are potentially changing
them and don't want to execute stale bytes.

What it does on most machines is call CPUID which is a serializing
instruction. And that's expensive.

However, the instruction cache is serialized when we're on the local CPU
and are changing the data through the same virtual address. So then, we
don't need the serializing CPUID but a simple control flow change. Last
being accomplished with a CALL/RET which the noinline causes.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Andy Lutomirski <luto@kernel.org>
[Linux commit 34bfab0eaf0fb5c6fb14c6b4013b06cdc7984466]

Ported to Xen.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/alternative.c
xen/arch/x86/livepatch.c